package com.ruyuan.common.web.model;

import lombok.Data;

import java.io.Serializable;

/**
 * @author xx
 */
@Data
public class WebResponse<T> implements Serializable {

    private static final long serialVersionUID = 4604228891364138311L;

    private boolean success;

    private T data;

    private String message;

    public static <T> WebResponse<T> successWithData(T data) {
        WebResponse<T> response = new WebResponse<>();
        response.setData(data);
        response.setSuccess(true);
        return response;
    }

    public static <T> WebResponse<T> failWithMsg(String msg) {
        WebResponse<T> response = new WebResponse<>();
        response.setMessage(msg);
        response.setSuccess(false);
        return response;
    }

}
